 <template>
  <el-table :data="data" @selection-change="handleSelectionChange">
    <template v-for="(item, index) in columns">
      <el-table-column
        :key="index"
        fixed
        v-if="!item.slot"
        :type="item.attr.type"
        :prop="item.attr.prop"
        :label="item.attr.label"
        :width="item.attr.width"
      ></el-table-column>

      <el-table-column
        :key="index"
        fixed
        v-else
        :label="item.attr.label"
        :width="item.attr.width"
      >
        <template slot-scope="scope">
          <slot :name="item.slot" v-bind:scope="scope"></slot>
        </template>
      </el-table-column>
    </template>
  </el-table>
</template>

<script>
export default {
  data() {
    return {};
  },
  props: ["data", "columns"],
  
  methods: {
    handleSelectionChange(val) {
      this.$emit("handleSelectionChange", val);
      if (this.autoScroll) {
        // scrollTo(0, 800)
      }
    }
  }
};
</script>

<style lang="scss" scoped>
@import "src/style/mixin";
</style>
